//
//  MIneShareFriendCell.swift
//  HappyEat
//
//  Created by ctx2016 on 17/1/12.
//  Copyright © 2017年 陌路是我. All rights reserved.
//

import UIKit
enum MIneShareFriendCellStyle {
    case YaoQingStyle
    case NormalStyle
}

class MIneShareFriendCell: UITableViewCell {
    
    var leftLabel:UILabel = UILabel.init()
    
    var leftLabel_Dow:UILabel = UILabel.init()
    
    var rightLabel:UILabel = UILabel.init()
    
    var iconRight:UIImageView = UIImageView.init(image: UIImage.init(named: "kelingqu"))
    
    var shawDowLabel:UILabel = UILabel.init()
    
    var cellType:MIneShareFriendCellStyle = .YaoQingStyle
    
    override func awakeFromNib() {
        super.awakeFromNib()
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)
    }
    init(style: UITableViewCellStyle, reuseIdentifier: String?,cellStyle:MIneShareFriendCellStyle) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        self.cellType = cellStyle
        self.setUI()
    }
    
    required init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
    }
    override func layoutSubviews() {
        super.layoutSubviews()
        if self.cellType == .YaoQingStyle{
            self.leftLabel.snp.makeConstraints({ (make) in
                make.left.equalTo(16)
                make.right.equalTo(-16)
                make.top.equalTo(12)
                make.bottom.bottom.equalTo(-12)
            })
            self.shawDowLabel.snp.makeConstraints({ (make) in
                make.left.equalTo(0)
                make.right.equalTo(0)
                make.height.equalTo(0.5)
                make.bottom.equalTo(0)
            })
        }else if self.cellType == .NormalStyle{
//            height = 64
            self.leftLabel.snp.makeConstraints({ (make) in
                make.left.equalTo(16)
                make.width.equalTo(k_Wide/2 - 16)
                make.top.equalTo(12)
                make.height.equalTo(14)
            })
            self.leftLabel_Dow.snp.makeConstraints({ (make) in
                make.left.equalTo(16)
                make.top.equalTo(self.leftLabel.snp.bottom).offset(12)
                make.height.equalTo(14)
                make.width.equalTo(k_Wide/2 - 16)
            })
            self.rightLabel.snp.makeConstraints({ (make) in
                make.left.equalTo(self.leftLabel.snp.right).offset(0)
                make.right.equalTo(-16)
                make.height.equalTo(14)
                make.top.equalTo(12)
            })
//            60 -18
            self.iconRight.snp.makeConstraints({ (make) in
                make.right.equalTo(-16)
                make.size.equalTo(CGSize.init(width: 60, height: 18))
                make.top.equalTo(self.rightLabel.snp.bottom).offset((38 - 18)/2)
            })
            self.shawDowLabel.snp.makeConstraints({ (make) in
                make.left.equalTo(0)
                make.right.equalTo(0)
                make.height.equalTo(0.5)
                make.bottom.equalTo(0)
            })
        }
    }
}
extension MIneShareFriendCell{
    func setUI(){
        if self.cellType == .YaoQingStyle {
            self.contentView.addSubview(self.leftLabel)
            self.contentView.addSubview(self.shawDowLabel)
            self.leftLabel.font = UIFont.systemFont(ofSize: 16)
            self.shawDowLabel.backgroundColor = .lightGray
        }else if self.cellType == .NormalStyle{
            self.contentView.addSubview(self.leftLabel)
            self.contentView.addSubview(self.leftLabel_Dow)
            self.contentView.addSubview(self.rightLabel)
            self.contentView.addSubview(self.iconRight)
            self.contentView.addSubview(self.shawDowLabel)
            self.leftLabel.font = UIFont.systemFont(ofSize: 14)
            self.leftLabel_Dow.font = UIFont.systemFont(ofSize: 14)
            self.rightLabel.textAlignment = .right
            self.rightLabel.textColor = .lightGray
            self.leftLabel.textColor = .lightGray
            self.leftLabel_Dow.textColor = .lightGray
            self.rightLabel.font = UIFont.systemFont(ofSize: 14)
            self.shawDowLabel.backgroundColor = .lightGray
        }
    }
}
